using System.Collections.Generic;
using System.Diagnostics;
using System.Xml.Serialization;

namespace Edmx.Storage
{
    [DebuggerDisplay("Role={Role}, Type={Type}, Multiplicity={Multiplicity}")]
    [XmlType(Namespace = EdmxConstants.StorageSchemaNamespace)]
    public class AssociationEnd : MetadataEntityBase<AssociationEnd>
    {
        [XmlElement("OnDelete")]
        public List<OnAction> OnDelete { get; set; }

        [XmlAttribute("Role")]
        public string Role { get; set; }

        [XmlAttribute("Type")]
        public string Type { get; set; }

        private Multiplicity? _multiplicity;

        [XmlAttribute("Multiplicity")]
        public Multiplicity Multiplicity
        {
            get { return _multiplicity ?? Multiplicity.One; }
            set { _multiplicity = value; }
        }

        public bool ShouldSerializeMultiplicity()
        {
            return _multiplicity.HasValue;
        }

    }
}